import {useEffect, useRef} from "react";
import {FormItemInstance} from "@taroify/core/form";
import {Field, Input} from "@taroify/core";

function FormPicker({
                        rules,
                        initVal,
                        name,
                        label,
                    }:{
    rules?: object[],
    initVal: string,
    name: string,
    label: string
}) {
    const itemRef = useRef<FormItemInstance>()

    useEffect(() => {
        itemRef.current?.setValue(initVal)
    }, [initVal])

    return (
        <Field label={label} ref={itemRef} name={name} rules={rules} clickable>
            <Input placeholder="请输入"/>
        </Field>
    )
}

export default FormPicker